package com.deyou.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.deyou.R;
import com.deyou.base.BaseActivity;
import com.deyou.model.HouseResourceAttrBean;
import com.deyou.util.AndroidUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class RoomAndBedActivity extends BaseActivity {

    @BindView(R.id.tv_mid_title)
    TextView tvMidTitle;
    @BindView(R.id.iv_add_people)
    ImageView ivAddPeople;
    @BindView(R.id.tv_people_number)
    TextView tvPeopleNumber;
    @BindView(R.id.iv_reduce_people)
    ImageView ivReducePeople;
    @BindView(R.id.iv_add_room)
    ImageView ivAddRoom;
    @BindView(R.id.tv_room_number)
    TextView tvRoomNumber;
    @BindView(R.id.iv_reduce_room)
    ImageView ivReduceRoom;
    @BindView(R.id.iv_add_bed)
    ImageView ivAddBed;
    @BindView(R.id.tv_bed_number)
    TextView tvBedNumber;
    @BindView(R.id.iv_reduce_bed)
    ImageView ivReduceBed;
    @BindView(R.id.iv_add_toilet)
    ImageView ivAddToilet;
    @BindView(R.id.tv_toilet_number)
    TextView tvToiletNumber;
    @BindView(R.id.iv_reduce_toilet)
    ImageView ivReduceToilet;
    @BindView(R.id.btn_next_step)
    TextView btnNextStep;

    private int peopleNum, roomNum, bedNum, toiletNum = 0;
    private HouseResourceAttrBean roomAndBedAttr;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_room_and_bed);
        ButterKnife.bind(this);
        roomAndBedAttr = (HouseResourceAttrBean) getIntent().getExtras().getSerializable("houseLocation");
        initView();
    }

    @Override
    protected boolean translucentStatusBar() {
        return super.translucentStatusBar();
    }

    private void initView(){
        tvMidTitle.setText("房间和床铺");
    }

    @OnClick({R.id.iv_left_back, R.id.iv_add_people, R.id.iv_reduce_people, R.id.iv_add_room, R.id.iv_reduce_room,
            R.id.iv_add_bed, R.id.iv_reduce_bed, R.id.iv_add_toilet, R.id.iv_reduce_toilet, R.id.btn_next_step})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.iv_left_back:
                finish();
                break;
            case R.id.iv_add_people:
                peopleNum += 1;
                tvPeopleNumber.setText(peopleNum + "");
                break;
            case R.id.iv_reduce_people:
                if (peopleNum > 0)
                    peopleNum -=1;
                tvPeopleNumber.setText(peopleNum + "");
                break;
            case R.id.iv_add_room:
                roomNum +=1;
                tvRoomNumber.setText(roomNum + "");
                break;
            case R.id.iv_reduce_room:
                if (roomNum > 0)
                    roomNum -= 1;
                tvRoomNumber.setText(roomNum + "");
                break;
            case R.id.iv_add_bed:
                bedNum += 1;
                tvBedNumber.setText(bedNum + "");
                break;
            case R.id.iv_reduce_bed:
                if (bedNum > 0)
                    bedNum -= 1;
                tvBedNumber.setText(bedNum + "");
                break;
            case R.id.iv_add_toilet:
                toiletNum += 1;
                tvToiletNumber.setText(toiletNum + "");
                break;
            case R.id.iv_reduce_toilet:
                if (toiletNum > 0)
                    toiletNum -= 1;
                tvToiletNumber.setText(toiletNum + "");
                break;
            case R.id.btn_next_step:
                roomAndBedAttr.resourceMaximumNum = peopleNum;
                roomAndBedAttr.resourceBedroomNum = roomNum;
                roomAndBedAttr.resourceBedNum = bedNum;
                roomAndBedAttr.resourceToiletNum = toiletNum;
                Bundle bundle = new Bundle();
                bundle.putSerializable("roomAndBenAttr", roomAndBedAttr);
                AndroidUtils.startNextActivity(RoomAndBedActivity.this, HouseDetailIntroActivity.class, bundle, false);
                break;
        }
    }
}
